<template>
  <div class="add-node">
    <el-popover
      v-model="showPopover"
      trigger="click"
      placement="right"
      width="200"
    >
      <div class="add-node-popover-body">
        <div class="add-node-popover-body__item">
          <el-button type="primary" icon="el-icon-s-check" circle @click="handleAddNode('approvalFlow')" />
          <div class="title">审批人</div>
        </div>
      </div>
      <template #reference>
        <el-button type="primary" icon="el-icon-plus" circle />
      </template>

    </el-popover>

  </div>
</template>
<script>
export default {
  name: 'AddNode',
  props: {
    nodeList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      showPopover: false
    }
  },
  methods: {
    handleAddNode(type) {
      this.showPopover = false
      if (type === 'approvalFlow') {
        this.$emit('onAdd', { nodeType: 1, nodeName: '审核人', approver: [] })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.add-node {
  display: flex;
  justify-content: center;
  width: 220px;
  padding: 20px 0 32px;
  position: relative;
  z-index: 1;
  > span {
    z-index: 1;
  }
  &:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    margin: auto;
    width: 2px;
    height: 100%;
    background-color: #cccccc;
  }
}
.add-node-popover-body {
  display: flex;
  &__item {
    flex: 1;
    .title {
      margin-top: 5px;
    }
  }
}
</style>
